<%=
  type = params.dig(:search, :auditable_type).presence
  id = params.dig(:search, :auditable_id).presence
  global = (!type || !id)
  page_title(global ? "Audits" : "Audits for #{type} #{id}")
%>

<%= search_form do %>
  <%= search_select :action, ["create", "update", "destroy"] %>
  <%= search_select :auditable_type, audited_classes.sort, label: "Resource" %>
  <%= search_select :user_id, User.pluck(:name, :id), live: true, label: "By" %>
<% end %>

<%= render 'table', audits: @audits, global: global %>
